package com.qqserver.service;

import com.qqcommon.User;

import java.util.HashMap;

/**
 * 用户仓库，存放注册的用户
 */
public class UserStore {
    //创建用户集合，存放多个用户
    //这里也可以使用ConcurrentHashMap集合，可以处理并发的集合，无线程安全问题
    private static HashMap<String, User> validUsers = new HashMap<>();

    //静态代码块
    static {
        validUsers.put("100",new User("100","123456"));
        validUsers.put("200",new User("200","123456"));
        validUsers.put("300",new User("300","123456"));
        validUsers.put("至尊宝",new User("至尊宝","123456"));

    }

    public static HashMap<String, User> getValidUsers() {
        return validUsers;
    }

    public static void setValidUsers(HashMap<String, User> validUsers) {
        UserStore.validUsers = validUsers;
    }
}
